package calendar;

/* this class is used to clean up when ctrl+c is used to terminate */
public class CatchSignal implements Runnable {
  static {
    System.loadLibrary("CatchSignal");
  }

  static CalendarMgr manager;

  public CatchSignal( CalendarMgr manager )
  {
    CatchSignal.manager = manager;
  }

  public native static void setControlCHandler();

  public static void callback() {
    System.err.println("Control-C hit!");
    manager.writeToDisk();
  }

  public void run() {
    setControlCHandler(); // never returns
  }
}
